
import time
import pygame
import mods.printlib
import random as rd
from colorama import init, Fore
import sys

init(autoreset = True)

__Arguments = sys.argv
def Exist_Argv(what):
    if what in __Arguments:
        return True
    else:
        return False

def printm(m, isGreen = False):
    if Exist_Argv('--NoPrompt'):
        return
    if isGreen:
        print(Fore.GREEN + f'[{time.ctime()[11:-5]}] [INFO] [mod] {m}')
    else:
        print(f'[{time.ctime()[11:-5]}] [INFO] [mod] {m}')
    
def print_warning(w):
    if Exist_Argv('--NoPrompt'):
        return
    print(f'[{time.ctime()[11:-5]}]' + Fore.RED + f' [WARN/ERROR] [mod] {w}')

Void = 0
Soft = 1
Hard = 2
Bed  = 3
BB   = 4
BB2  = 5

FPS = None
_VERSION__ = None

def inits(FpsObject, ver):
    global FPS, _VERSION__
    FPS, _VERSION__ = FpsObject, ver
    printm('成功获取帧对象。')

def cint(t):
    return t if type(t) is int else int(t)

def RandomColor():
    return (rd.randint(0, 254), rd.randint(0, 254), rd.randint(0, 254))

def Pause():
    c = RandomColor()
    while True:
        FPS.tick(8)
        mods.printlib.xyprint('      已暂停，点击ESC继续', color = c, place = ('center', 8))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                return
                break;
                
        pygame.display.flip()